home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Format 1994 October
/
Macformat17.cdr
/
Shareware City
/
Developers
/
shutdown-fx-20-c
/
sfx startup app ƒ
/
Shell ƒ
/
environment.c
< prev
next >
Wrap
Text File
|
1994-07-11
|
3KB
|
87 lines
/**********************************************************************\
File: environment.c
Purpose: This module handles initializing the environment and
checking for various environmental characteristics.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program in a file named "GNU General Public License".
If not, write to the Free Software Foundation, 675 Mass Ave,
Cambridge, MA 02139, USA.
\**********************************************************************/
#include "environment.h"
#include "program globals.h"
#include "GestaltEqu.h"
#include "Traps.h"
Boolean gHasFSSpecs; /* FSSpec calls supported? */
Boolean gHasNotificationManager; /* notification manager present? (cf error.c) */
Boolean gHasGestalt; /* Gestalt() implemented? */
/* This is to stop the compiler from using Gestalt glue without killing
all the other pre-system 7 glue for other routines. */
#pragma parameter __D0 RealGestalt(__D0,__A1)
pascal OSErr RealGestalt(OSType selector,long *response) = {0xA1AD,0x2288};
#define Gestalt RealGestalt
#define GESTALT_TRAP 0xA1AD /* _Gestalt */
#define GetTrapType(T) (((T & 0x0800) > 0) ? ToolTrap : OSTrap)
#define NumToolboxTraps() ((NGetTrapAddress(_InitGraf, ToolTrap) == \
NGetTrapAddress(0xAA6E, ToolTrap)) ? 0x0200 \
: 0x0400)
Boolean TrapAvailable(short theTrap);
Boolean TrapAvailable(short theTrap)
{
TrapType tType;
tType=GetTrapType(theTrap);
if (tType==ToolTrap)
{
theTrap=theTrap&0x07FF;
if (theTrap>=NumToolboxTraps())
theTrap=_Unimplemented;
}
return (NGetTrapAddress(theTrap, tType)!=NGetTrapAddress(_Unimplemented, ToolTrap));
}
short InitTheEnvironment(void)
/* called very early -- this uses Gestalt to check out the computing environment;
see above for explanations of variables */
{
long gestalt_temp;
OSErr isHuman;
SysEnvRec theWorld;
if (SysEnvirons(1, &theWorld)==envNotPresent)
return kSystemTooOld;
gHasGestalt=TrapAvailable((short)GESTALT_TRAP);
if (!gHasGestalt)
return kSystemTooOld; /* requires Gestalt to function properly */
isHuman=Gestalt(gestaltFSAttr, &gestalt_temp);
gHasFSSpecs=((isHuman==noErr) && (gestalt_temp&(1<<gestaltHasFSSpecCalls)));
isHuman=Gestalt(gestaltNotificationMgrAttr, &gestalt_temp);
gHasNotificationManager=(!((isHuman) ||
(((gestalt_temp >> gestaltNotificationPresent) & 0x01) != 1)));
return 0;
}